package com.abc.service;

import com.abc.entity.Jiaoshi;
import com.abc.mapper.JiaoshiMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JiaoshiService {

    @Autowired
    private JiaoshiMapper jiaoshiMapper;

    public List<Jiaoshi> findAllJiaoshi(){
        return jiaoshiMapper.findAllJiaoshi();
    }
    public String addJiaoshi(Jiaoshi jiaoshi){
        Jiaoshi jiaoshi1 = jiaoshiMapper.findByJiaoshiXingming(jiaoshi.getXingming());
        if(jiaoshi1!=null){
            return "姓名已存在,添加失败";
        }
        int k = jiaoshiMapper.insertJiaoshi(jiaoshi);
        if(k>0){
            return "添加成功";
        }else{
            return "添加失败";
        }
    }

}
